<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page import="com.scalar.chiptrack.utils.ConfigManager" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/quotationReportAction.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<%
    String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
%>
<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
</HEAD>
<script language="javascript">

    var dateElement = "";
    function openCalendar(dateValue)
    {
        dateElement = dateValue;
        newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
        newWindow.moveTo(550,180);
        newWindow.focus();
    }

    function assignDate(passedValue)
    {
        dateElement.value=passedValue;
        window.focus();
    }
    function validateFromAndToDates()
    {
        var formdoc = document.quotationReportForm;
        errMsg = '';
        var pa	= document.getElementById("errors")

        if(chkDate(formdoc.fromDate.value,'From-Date','N') == false)
        {
            pa.innerHTML = errMsg;
            formdoc.fromDate.focus();
            return false;
        }

        if(chkDate(formdoc.toDate.value,'To-Date','N') == false)
        {
            pa.innerHTML = errMsg;
            formdoc.toDate.focus();
            return false;
        }

        if(formdoc.fromDate.value!='' && formdoc.toDate.value!='')
        {
            if (!validateDateOut(formatDateAsMMDDYYYY(formdoc.fromDate.value),formatDateAsMMDDYYYY(formdoc.toDate.value)))
            {
                pa.innerHTML = "<LI>To Date cannot be less than From Date</LI>";
                formdoc.toDate.focus();
                return false;
            }
        }
        return true;
    }
    function submitReport( )
    {
        var pa	= document.getElementById("errors")
        var form = document.quotationReportForm;
        pa.innerHTML = '';
        if( validateFromAndToDates() )
        {
            //var newWindow;
            //var url = '<%=chipTracContext%>/quotationReportAction.do?action=quotationReportxls&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6;
            //newWindow = window.open ( url, 'quotationReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
            form.action = '<%=chipTracContext%>/quotationReportAction.do?action=quotationReportxls';
            form.submit();   
        }

}

</script>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" >
<!-- Top Header Start-->

    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>

<!-- Top Header End-->
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
    <!-- Side Navigation start -->
        <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/sales_report_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/external_reports_menu.jsp" %>
        </logic:notEqual>
    <!-- end of the side navigations -->
    </TD>
    <TD bgcolor="#ffffff">
        <IMG height="9" src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="8"></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="2"></TD>
        <TD valign="top" width="100%">
        <IMG height="1" src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width="500" border="0">
        <BR>
        <html:form name="quotationReportForm" type="com.scalar.chiptrack.sales.reports.forms.QuotationReportForm" action="/quotationReportAction">
        <TABLE border="0" width="100%" align="center">
            <TR><TD colspan="7" class="NArialW" align="center">Quotation Report</TD></TR>
            <TR><TD colspan="7">&nbsp;</TD></TR>
            <TR>
                <TD colspan="7" align="left" class="NArialL"><font id="errors" color="red"></font>
                  <chiptrack:info styleClass="NArialL" />
                  <chiptrack:errors styleClass="NArialL" />
                  <chiptrack:messages type="info" styleClass="NArialL" />&nbsp;
                </TD>
            </TR>
            <TR>
                <TD colspan="7">
                    <TABLE align="center" border="0" width="100%" cellspacing="3" cellpadding="2">
                        <TR>
                            <TD width="10%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top' >Customer</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <nested:select property="customerId" styleClass="txfield" style="width:200px" multiple="true" size="5">
                                    <html:options collection="customerList" property="value" labelProperty="label"/>
                                </nested:select>
                            </TD>
                            <TD width="5%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top'><bean:message key="label.mfgPartNumber" /></TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <nested:select property="productId" styleClass="txfield" style="width:200px" multiple = "true" size = "5">
                                    <html:option value="0">All Products</html:option>
                                    <html:options collection="productList" property="value" labelProperty="label"/>
                                </nested:select>
                            </TD>
                            <TD width="10%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top">Region</TD>
                            <TD width="20%" class="NArialL">
                                <nested:select property="regionName" styleClass="txfield" style="width:200px">
                                    <html:option value="0">All Regions</html:option>
                                    <html:options collection="regionList" property="label" labelProperty="label"/>
                                </nested:select>
                            </TD>
                            <TD width="5%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top" ><bean:message key="label.sales.endCustomer"/></TD>
                            <TD width="20%" class="NArialL" valign="top">
                                <nested:select property="endCustomerId" styleClass="txfield" style="width:200px" >
                                    <html:option value="0">All <bean:message key="label.sales.endCustomer"/>s</html:option>
                                    <html:options collection="endCustomerList" property="value" labelProperty="label"/>
                                </nested:select>
                            </TD>
                            <TD width="10%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top">Sales Person</TD>
                            <TD width="20%" class="NArialL" nowrap>
                               <nested:select property="salesPersonName" styleClass="txfield" style="width:200px" >
                                    <html:option value="0">All SalesPersons</html:option>
                                    <html:options collection="salesPersonList" property="salesPerson" labelProperty="salesPerson"/>
                                </nested:select>
                            </TD>
                            <TD width="5%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top" ><bean:message key="label.sales.endUser"/></TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <nested:select property="endUserId" styleClass="txfield" style="width:200px" >
                                    <html:option value="0">All <bean:message key="label.sales.endUser"/>s</html:option>
                                    <html:options collection="endUserList" property="value" labelProperty="label"/>
                                </nested:select>
                            </TD>
                            <TD width="10%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top">From-Date</TD>
                            <TD width="20%" class="NArialL" nowrap>
                                <nested:text property="fromDate" size="12" styleClass="txfield"/>
                                <a href="javascript:openCalendar(document.quotationReportForm.fromDate)"onmouseover="window.status='Click to Select From Date';return true"onmouseout="window.status='';return true"title="Click here to Select From Date">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=18 width=18></a>
                            </TD>
                            <TD width="5%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top" >To-Date</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <nested:text property="toDate" size="12" styleClass="txfield"/>
                                <a href="javascript:openCalendar(document.quotationReportForm.toDate)"onmouseover="window.status='Click to Select To Date';return true"onmouseout="window.status='';return true"title="Click here to Select To Date">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=18 width=18></a>
                            </TD>
                            <TD width="10%">&nbsp;</TD>
                        </TR>
                        <TR><TD colspan="7"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></TD></TR>
                        <TR>
                            <TD colspan="7" align=center>
                                <a href="javascript:submitReport();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Quotation Report';return true" onmouseout="window.status='';return true" title='Click to Generate Quotation Report'></a>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="javascript:document.quotationReportForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to reset search';return true" onmouseout="window.status='';return true" title="Click here to reset search"></a>
                            </TD>
                        </TR>
                        <TR><TD colspan="7"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></TD></TR>
                    </TABLE>
                </TD>
            </TR>
        </TABLE>
        </html:form>
    </TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
